import svgIcon from './svg-icon/index.vue'
import popup from './popup/index.vue'
import { defineAsyncComponent } from 'vue'
export default {
  install(app) {
    // app.component('my-svg-icon', svgIcon)
    // app.component('my-popup', popup)

    // 1 获取当前路径下所有文件夹中的index.vue
    const components = import.meta.glob('./*/index.vue')
    // 2 遍历获取到的组件模块
    for (const [fullpath, fn] of Object.entries(components)) {
      const componentsName = 'my-' + fullpath.replace('./', '').split('/')[0]
      // 3 利用app.compent注册
      app.component(componentsName, defineAsyncComponent(fn))
    }
  }
}
